package com.ruoyi.post.service.impl;

import com.ruoyi.post.domain.PostContent;
import com.ruoyi.post.mapper.PostContentMapper;
import com.ruoyi.post.service.IPostContentServise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class IPostContentServiseImpl implements IPostContentServise {
    @Autowired
    private PostContentMapper postContentMapper;

    @Override
    public void insert(PostContent postContent) {
        postContentMapper.insert(postContent);
    }

    @Override
    public void delete(String id) {
        postContentMapper.deleteById(id.toString());
    }

    @Override
    public void update(PostContent postContent) {
        delete(postContent.getId().toString());
        insert(postContent);
    }

    @Override
    public List<PostContent> list(PostContent postcontent) {

        return postContentMapper.findAll();
    }

    @Override
    public PostContent getById(String id) {
        Optional<PostContent> byId = postContentMapper.findById(id);
        PostContent content = byId.get();
        return content;
    }
}
